<!DOCTYPE html>
<html>
<head>
<title>卡片规则管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<#include "../../../../include/resources.html">
<script type="text/javascript">
	var dataGrid;
	var winWidth =  900; //弹出窗口宽度
	var winHeight = 500; //弹出窗口高度
	var editTitle = "编辑卡片规则";
	var editUrl =  "/modules/additional/card/cardRule/cardRuleEditPage.html";
	var detailTitle = "卡片规则详情";
	var detailUrl = "/modules/additional/card/cardRule/cardRuleDetailPage.html";
	var addTitle = "添加卡片规则";
	var addUrl = "/modules/additional/card/cardRule/cardRuleAddPage.html";
	var disableTitle = "禁用";
	var disableUrl = "/modules/additional/card/cardRule/cardRuleDisable.html";
	var enableTitle = "启用";
	var enableUrl = "/modules/additional/card/cardRule/cardRuleEnable.html";
	var txt1 = "禁用";
	var txt2 = "启用";
	var val1 = 1;
	var val2 = 0;

	$(function() {
		dataGrid = $('#dataGrid').datagrid({
			url : 'cardRuleList.html',
			fit : true,
			fitColumns : true,
			border : false,
			pagination : true,
			idField : 'id',
			pageSize : pageSize,
			pageNums :1,
			pageList : pageList,
			sortName : 'id',
			sortOrder : 'asc',
			checkOnSelect : false,
			selectOnCheck : false,
			nowrap : false,
			singleSelect:true,
			columns : [ [
				{ field: 'id', title: '编号', width: 50, checkbox : false},
				{ field: 'name', title: '名称', width: 100, checkbox : false},
				{ field: 'typeStr', title: '卡片类型', width: 80, sortable:false },
				{ field: 'validDay', title: '有效期(天)', width: 80, sortable:false },
				{ field: 'total', title: '卡片总数', width: 70, sortable:false },
				{ field: 'issueNum', title: '已发放数量', width: 70, sortable:false },
				{ field: 'status', title: '状态', width: 50, sortable:false,formatter:
						function(value,row,index){
							if(row.status == 1) {
								return "启用";
							} else {
								return "禁用";
							}
						} },
				{ field : 'showInfo',
					title : '其他信息',
					width :75,
					fixed : true,
					align : 'center',
					formatter : function(value, row, index) {
						var content = '<a href="javascript:void(0);" class="j-showInfo">查看<i class="iconfont">&#xe639;</i></a>'
								+ '<div class="showInfoSingleDiv">'
								+ '<div class="showInfo">'
								+ '<em></em><h2>卡片规则信息</h2>'
								+ '<ul>'
								+ '<li>'
								+ '<span>添加时间：</span>'
								+ getLocalTime(row.addTime,4)
								+ '</li>'
								+ '<li>'
								+ '<span>IP：</span>'
								+ row.addIp
								+ '</li>'
								+ '<li>'
								+ '<span>卡片规则描述：</span>'
								+ row.description
								+ '</li>'
								+ '</ul></div></div>';
						return content;
					}
				},
				{ field : 'action',
					title : '操作',
					width : 75,
					fixed : true,
					align : 'center',
					formatter : function(value, row, index) {
						var str = '';
						str += '<dl>';
						str += '<dt><a href="javascript:void(0);" onclick="$.fn.dataGridOptions.closeFun('+row.id+',detailTitle,winWidth,winHeight,detailUrl);" title="'+detailTitle+'">详情</a><i class="iconfont">&#xe639;</i></dt>' ;
						str += '<dd>';
						str += '<a href="javascript:void(0);" onclick="$.fn.dataGridOptions.editFun('+row.id+',editTitle,winWidth,winHeight,editUrl);" title="'+editTitle+'">编辑</a>';
						if(row.status==0){
							str += '<a href="javascript:void(0);" onclick="$.fn.dataGridOptions.recordOptFun('+row.id+',enableUrl,txt2,val2);">启用</a>';
						} else if(row.status==1){
							str += '<a href="javascript:void(0);" onclick="$.fn.dataGridOptions.recordOptFun('+row.id+',disableUrl,txt1,val1);">禁用</a>';
						}
						str += '</dd>'
						str +=  '</dl>'
						return str;
					}
				}

			] ],
			toolbar : '#toolbar',
			onLoadSuccess : function() {
				$('#searchForm table').show();
				parent.$.messager.progress('close');
			}
		});
	});

</script>
</head>
<body style="padding:0 20px;" >
	<div class="easyui-layout" data-options="fit : true,border : false">
		<div data-options="region:'north',border:false,collapsible:false" id="searchBox">
			<div class="sLeft">
	            <form id="searchForm">
	            	<input type="text"  name="searchName" id="searchName" class="sInput" placeholder="输入名称进行搜索" autocomplete="off" onkeydown="if(event.keyCode == 13){ $.fn.dataGridOptions.searchFun('#searchForm');return false;}"/><a href="javascript:;" title="查询" class="sBtn" onclick="$.fn.dataGridOptions.searchFun('#searchForm');">查询</a>
	            	 <a href="javascript:void(0);" class="reloadIcon" onclick="dataGrid.datagrid('reload');" title="刷新" ><i class="iconfont">&#xe603;</i></a>
	            </form>
            </div>
            <form id="showAdw">
	        </form>
            <div class="sRight">
				<a onclick="$.fn.dataGridOptions.addFun(-1,addTitle,winWidth,winHeight,addUrl);" href="javascript:void(0);" class="addBtn"><i class="iconfont">&#xe629;</i>新增卡片规则</a>
			</div>
		</div>
		<div data-options="region:'center'" style="margin-top:30px;padding-bottom:30px;">
			<table id="dataGrid"></table>
		</div>
	</div>
</body>
</html>
<script src="${theme_dir}/js/search.js"></script>